#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -x /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -x /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi

#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat > cc_fop_cc3.info <<%EOF%
   cc_fop_cc3
   -----------
   Molecule:         HF in C2v
   Wave Function:    CC3 with frozen core  / 6-31G
   Test Purpose:     First-order one-electron properties
%EOF%

#######################################################################
#  INTEGRAL INPUT
#######################################################################
cat > cc_fop_cc3.mol <<%EOF%
BASIS
6-31G
CCSD(T) unrelaxed FOP
Dum di dum di da
    2    2  X  Y      1.00D-15
        9.0   1    2    1    1
F     0.0000000000000000   0.000000000   0.08729478
        1.0   1    1    1
H     0.0000000000000000   0.000000000  -1.64558444
%EOF%

#######################################################################
#  DALTON INPUT
#######################################################################
cat > cc_fop_cc3.dal <<%EOF%
**DALTON INPUT
.RUN WAVE FUNCTIONS
**INTEGRAL
.DIPLEN
.THETA
.EFGCAR
.SECMOM
.DARWIN
.MASSVELO
**WAVE FUNCTION
.CC
*SCF INP
.THRESH
 1.0D-9
*CC INP
.CC3
.PRINT
 6
.FROIMP
 1 0 0 0
 0 0 0 0
.THRENR
1.0D-10
.THRLEQ
1.0D-8
*CCFOP
.NONREL
.ALLONE
**END OF DALTON INPUT
%EOF%
#######################################################################

 

#######################################################################

#######################################################################
#  CHECK SCRIPT
#######################################################################
echo $CHECK_SHELL >cc_fop_cc3.check
cat >>cc_fop_cc3.check <<'%EOF%'
log=$1

if [ `uname` = Linux ]; then
   GREP="egrep -a"
else
   GREP="egrep"
fi

if $GREP -q "not implemented for parallel calculations" $log; then
   echo "TEST ENDED AS EXPECTED"
   exit 0
fi

# SCF, MP2 and CCSD energies:
CRIT1=`$GREP "Final * HF energy: * -99\.9834089....." $log | wc -l`
CRIT2=`$GREP "Total MP2   energy: * -100\.1110833.." $log | wc -l`
CRIT3=`$GREP "Total CC3   energy: * -100\.114449(7|8).." $log | wc -l`
TEST[1]=`expr $CRIT1 \+ $CRIT2 \+ $CRIT3` 
CTRL[1]=5
ERROR[1]="ENERGIES NOT CORRECT"


# CC3 first order properties :
CRIT1=`$GREP  "   z *  ( -|-0)\.860699(4|5). * -2\.187679.." $log | wc -l`
CRIT2=`$GREP  "   1 *  ( -|-0)\.7623851. * ( |0)\.0000000. * ( |0)\.0000000" $log | wc -l`
CRIT3=`$GREP  "   2 * ( |0)\.0000000. * ( -|-0)\.7623851. * ( |0)\.0000000" $log | wc -l`
CRIT4=`$GREP  "   3 * ( |0)\.0000000. * ( |0)\.0000000. * 1\.524770." $log | wc -l`
CRIT5=`$GREP  "   1 * 4\.050307.. * ( |0)\.0000000. * ( |0)\.0000000" $log | wc -l`
CRIT6=`$GREP  "   2 * ( |0)\.0000000. * 4\.050307.. * ( |0)\.0000000" $log | wc -l`
CRIT7=`$GREP  "   3 * ( |0)\.0000000. * ( |0)\.0000000. * 5\.302068(5|6)" $log | wc -l`
CRIT8=`$GREP  "Alfa\*\*2 Invariant: *  19\.95910" $log | wc -l`
CRIT9=`$GREP  "Beta\*\*2 Invariant: *   1\.56690" $log | wc -l`
CRIT10=`$GREP "Isotropic Property:  *   4\.46756. a\.u\." $log | wc -l`
CRIT11=`$GREP "Property anisotropy invariant: * 1\.251761 a\.u\." $log | wc -l`
CRIT12=`$GREP "   1 * -1\.49036(0|1).. * ( |0)\.0000000. * ( |0)\.0000000" $log | wc -l`
CRIT13=`$GREP "   2 * ( |0)\.0000000.  * -1\.49036(0|1).. * ( |0)\.0000000" $log | wc -l`
CRIT14=`$GREP "   3 * ( |0)\.0000000. * ( |0)\.0000000. * 2\.98072.." $log | wc -l`
CRIT15=`$GREP "H       2    Vx = * ( -|-0)\.3235(8|9). * ( -|-0)\.21745. * ( -|-0)\.077682" $log | wc -l`
CRIT16=`$GREP "H       2    Vy = * ( -|-0)\.3235(8|9). * ( -|-0)\.21745. * ( -|-0)\.077682" $log | wc -l`
CRIT17=`$GREP "H       2    Vz = * ( |0)\.6471(7|8). * ( |0)\.43490. * ( |0)\.155365" $log | wc -l`
CRIT18=`$GREP "   1-elec\. Darwin term: * ( |0)\.31639." $log | wc -l`
CRIT19=`$GREP "   Mass-Velocity term: * ( -|-0)\.40228" $log | wc -l`
CRIT20=`$GREP "   Mass-Velocity \+ 1-elec\. Darwin terms\: * ( -|-0)\.0858(8|9).." $log | wc -l`
CRIT21=`$GREP "Ecorr = * -100\.114449(7|8)..." $log | wc -l`

TEST[2]=`expr $CRIT1  \+ $CRIT2  \+ $CRIT3  \+ $CRIT4  \+ $CRIT5  \+ \
              $CRIT6  \+ $CRIT7  \+ $CRIT8  \+ $CRIT9  \+ $CRIT10 \+ \
              $CRIT11 \+ $CRIT12 \+ $CRIT13 \+ $CRIT14 \+ $CRIT15 \+ \
              $CRIT16 \+ $CRIT17 \+ $CRIT18 \+ $CRIT19 \+ $CRIT20 \+ \
              $CRIT21 `
CTRL[2]=21
ERROR[2]="CC3 FIRST ORDER PROPERTIES NOT CORRECT"


PASSED=1
for i in 1 2
do 
   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
     PASSED=0
   fi
done 

if [ $PASSED -eq 1 ]
then
  echo TEST ENDED PROPERLY
  exit 0
else
  echo THERE IS A PROBLEM 
  exit 1
fi

exit 0

%EOF%
chmod +x cc_fop_cc3.check
#######################################################################
